Xfce Wiki

Sub domains
 

This is an old revision of the document!


xfce4-genmon-plugin - Genmon

This plugin cyclically spawns the indicated script/program, captures its output (stdout) and displays the resulting string into the panel.

The string can also contain markup to displayed an image, a bar, a button and a personalized tooltip.

Important Note about version 4.2.0

In version 4.2.0, the backend settings have been migrated from rc files to xfconf. Individual plugin settings will not be automatically migrated to xfconf and each plugin will need to be manually re-configured. A script has been developed (https://gitlab.xfce.org/panel-plugins/xfce4-genmon-plugin/-/blob/master/scripts/migrate_to_xfconf.sh) that can offer assistance for the migration.

Usage

If you want the plugin to display only text (original version), enter the command in the Command field of the Properties section of the plugin. Otherwise, xml tags are used to display content on the plugin.

XML Tags

If you want the plugin to display a personalized Text, Image, Icon, Tooltip or Bar, you should develop (or get) a script returning a XML string, and enter the path of this script in the Command field of the Property section of the plugin.

The XML tags which can be used:

  • <txt>Text to display</txt>
    • Displays the “Text to display” directly on the plugin.
    • eg. echo “<txt>Hello World!</txt>”
    • <txtclick>The command to be executed when clicking on the text</txtclick>
      • If displaying text, this tag will allow for a program/script to be run when the text is clicked.
      • eg. echo “<txt>File Manager</txt><txtclick>thunar</txtclick>”
  • <img>Path to the image to display</img>
    • Display an image on the plugin using the complete path and name to the image file.
    • eg. echo “<img>/usr/share/pixmaps/xfce4_xicon.png</img>”
    • <click>The command to be executed when clicking on the image</click>
      • If using an image, this tag will allow for a program/script to be run when the image is clicked.
      • eg. echo “<img>/usr/share/pixmaps/xfce4_xicon.png</img><click>xfce4-about</click>”
  • <icon>Themed icon to be displayed</icon>
    • Display an icon from the current icon theme using only the icon name.
    • eg. echo “<icon>org.xfce.mousepad</icon>”
    • Note: the <icon> tag allows the following functionality:
      • image changes with the icon theme
      • supports panel's Adjust Icon Size Automatically functionality
      • supports light/dark symbolic icon auto-colour changes
    • <iconclick>The command to be executed when clicking on the icon</click>
      • If using an icon, this tag will allow for a program/script to run when the icon is clicked.
      • eg. echo “<icon>org.xfce.mousepad</icon><iconclick>mousepad</iconclick>”
  • <tool>Tooltip text</tool>
    • Display specific content in a tooltip.
    • eg. echo “<tool>My custom tooltip text</tool>”
    • Note:
      • To hide the tooltip bubble, use an empty tool tag, eg: echo “<tool></tool>”
  • <bar>Percentage to display in the bar</bar>
    • Display a value-based progress bar on the plugin.
    • eg. echo “<bar>42</bar>” (this will show a progress bar at 42%)
  • <css>embedded CSS tweaks (see below)</css>
    • This tag will allow the embedding of css tweaks directly into the plugin.
    • eg. echo “<css>.genmon_valuebutton {background-color:red; color:yellow} .genmon_label {color:green}</css>”
    • More information on css and css tweaking of the plugin in the Advanced Features section below.

If None of the tags are detected in the result of the command, the plugin reverts to its original behavior (displaying the result of the command).

Example Script (cpu temperature)

Here's a simple example of a plugin displaying the Temp of the CPU in the panel (with an icon) and the Freq in a Tooltip:

cuptemp.sh
#!/bin/bash
echo "<img>/usr/share/icons/Bluecurve/16x16/apps/gnome-monitor.png</img>"
declare -i cpuFreq
cpuFreq=$(cat /proc/cpuinfo | grep "cpu MHz" | sed 's/\ \ */ /g' | cut -f3 -d" " | cut -f1 -d".")
if [ $cpuFreq -ge 1000 ]
then
  cpu=$(echo $cpuFreq | cut -c1).$(echo $cpuFreq | cut -c2)GHz
else
  cpu=${cpuFreq}MHz
fi
echo "<txt>"$(cat /proc/acpi/thermal_zone/THM/temperature | sed 's/\ \ */ /g' | cut -f2 -d" ")" C</txt>"
echo "<tool>Freq: "$cpu"</tool>"

PS: Depending on your configuration, you should change the image path.

Another Example Script (keyboard leds)

Here's a another simple example of a plugin displaying the keyboard LED states of the caps, num and scroll lock keys:

kbdleds.sh
#!/bin/bash
# genmon script to display status of keyboard LEDS
# genmon properties:
#   Command = path to this script
#   Label = optional Label preceeding output
#   Period = how often to check the status - the lower the number the quicker the response
#   Font = the font to use - monospace fonts keep the widget from resizing
 
# configuration
FG="white" # foreground colour
OBC="red" # background colour of cell text if active
 
# code
STATE=($(xset q | grep Caps\ Lock | awk '{print $4" "$8" "$12}'))
CAPS=$([[ ${STATE[0]} == "on" ]] && echo "<span foreground='$FG' background='$OBC'>C</span>" || echo "<span foreground='$FG'>c</span>")
NUM=$([[ ${STATE[1]} == "on" ]] && echo "<span foreground='$FG' background='$OBC'>N</span>" || echo "<span foreground='$FG'>n</span>")
SCROLL=$([[ ${STATE[2]} == "on" ]] && echo "<span foreground='$FG' background='$OBC'>S</span>" || echo "<span foreground='$FG'>s</span>")    
 
# genmon    
echo "<txt>$CAPS$NUM$SCROLL</txt>"
echo "<tool>CAPS = ${STATE[0]}"
echo "NUM = ${STATE[1]}"
echo "SCROLL = ${STATE[2]}</tool>"
 
exit 0

Back To Top


Advanced Features

Pango Markups in the <txt> and <tool> tags

Both the <txt> and <tool> tags support Pango Markups. See: https://developer.gnome.org/pygtk/stable/pango-markup-language.html. With Pango markups, you can change text attributes like font colour, weight, size, etc, in your output string. To do so, use the <span></span> tag within the <txt></txt> or <tool></tool> tags. For example, to display the output in bold red, you could use something like:

echo "<txt><span weight='Bold' fgcolor='Red'>Test</span></txt>"

Refer to the previous link for information on all of the properties that can be set.

Refreshing the plugin

The xfce4-genmon-plugin supports xfce4-panel plugin-event functionality to remotely force the plugin to refresh. To refresh the plugin, issue the command:

xfce4-panel --plugin-event=genmon-X:refresh:bool:true    

where “genmon-X” is the widget name of the particular genmon instance. To get this name, go to the panel properties screen and on the Items tab, hover your mouse over the genmon plugin to get it's internal name.

As of version 4.2.0, there is also now an “Update Now” menu item on the plugin right-click menu to immediately update the plugin (this does not reset the timer).

Enhanced Gtk3 CSS Styling Capabilities

CSS styling capabilities have been enhanced by providing style classes for all elements of the plugin that can be styled via themes or individual overrides (~/.config/gtk-3.0/gtk.css). For more information, see: https://git.xfce.org/panel-plugins/xfce4-genmon-plugin/tree/CSS%20Styling.txt.

As of version 4.2.0, this plugin also supports CSS tags (special thanks to @stergem) that allow you to tweak the plugin css directly from within the command/script using <css></css> tags. For example:

#!/bin/bash
echo "<txt>Hello</txt>"
echo "<txtclick>mousepad</txtclick>"
echo "<css>.genmon_valuebutton {background-color:red; color:yellow} .genmon_label {color:green}</css>"
echo "<tool>Hello there</tool>"

Back To Top


Screenshots

:panel-plugins:xfce4-genmon-plugin.png

In this example, the plugin is used to (from left to right):

  1. display the date
  2. mount/unmount an USB disk with 1 click
  3. display the CPU temperature (and the frequency in the tooltip)
  4. display the HD temperature
  5. display the state of the 2 batteries of my laptop
  6. display the WIFI quality

:panel-plugins:gmail.png

In ^this^ example, we see the gmail checker script in action:

  1. plugin display shows icon indicating state of new emails available
  2. tooltip shows number of new messages, sender/subject of new messages, and timestamp of last check
  3. clicking on the icon launches your email program

:panel-plugins:sysstat.png

In ^this^ example, we see the sysstat script in action:

  1. plugin display shows optional icon and 3 readings (cpu, memory, hard drive usage)
  2. tooltip shows top 5 cpu and memory uses and hard drive space usage
  3. clicking on the text output launches xfce4-taskmanager (ver. 3.99 or greater)

:panel-plugins:googcal.png

In ^this^ example, we see the google calendar checker script in action:

  1. plugin display shows icon indicating state of new upcoming appointments
  2. tooltip shows a listing of upcoming appointments
  3. clicking on the icon opens google calendar in your browser

:panel-plugins:twit0.png :panel-plugins:twit1.png

In ^this^ example, we see the twit (Twitter Timeline Notifier) script in action:

  1. plugin display shows icon indicating state of new tweets in your timeline
  2. libnotify notifications will be sent with new tweets
  3. tool tip will show new and optionally recent tweets
  4. clicking on the plugin icon can either execute a program, display a yad dialog with all recent tweets (above image), or compose and send a tweet.

Most of the scripts are available in the plugin archive.

Back To Top


Latest Release

  • xfce4-genmon-plugin 4.2.0 released (2023/04/17 01:24)
    xfce4-genmon-plugin 4.2.0 is now available for download from https://archive.xfce.org/src/panel-plugins/xfce4-genmon-plugin/4.2/xfce4-genmon-plugin-4.2.0.tar.bz2 https://archive.xfce.org/src/panel-plugins/xfce4-genmon-plugin/4.2/xfce4-genmon-plugin-4.2.0.tar.bz2?sha1 https://archive.xfce.org/src/panel-plugins/xfce4-genmon-plugin/4.2/xfce4-genmon-plugin-4.2.0.tar.bz2?sha256 What is xfce4-genmon-plugin? ============================ This plugin cyclically spawns the indicated script/program, captures its output (stdout) and displays the resulting string into the panel. The string can also contain markup to displayed an image, a bar, a button and a personalized tooltip. Website: https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin Release notes for 4.2.0 ======================= - Add shell script to migrate settings to xfconf - Fix GDK_Critical - Fixed deskbar support. Issue #8 - Add Update Now menu option to right-click menu - build: Add GLib requirement - build: Fix autotools warnings - Use "logo-icon-name" instead of "logo" in about dialog - ***Migrate settings to xfconf - Remove unused variable - Fix intltool lock file bug in make distcheck - Remove closing of standard file descriptors in the child process - Update COPYING - Add tag support - fixed .genmon_label and -gtk-icon transform bugs - Fix code indentation and readalility - Add support for single and multi-row panel layout options - Added support for XML tag. Changed default progressbar width to 4px - automake: Modernize following other projects - autoconf: Some updates - Update `.gitignore` - Add missing comments to code functions - Fix indentation - Translation updates

Back to Top


Source code repository

Reporting Bugs

Back To Top


Return to Main Xfce4-panel page